Cloning a pluggable database in read-write mode

ABSTRACT

Embodiments create a clone of a PDB while the PDB accepts write operations. While the PDB remains in read-write mode, the DBMS copies the data of the PDB and sends the data to a destination location. The DBMS performs data recovery on the PDB clone based on redo entries that record changes made to the source PDB while the DBMS copied the source PDB files. This data recovery makes all changes, to the PDB clone, that occurred to the source PDB during the copy operation. The redo information, on which the data recovery is based, is foreign to the PDB clone since the redo entries were recorded for a different PDB. In order to apply foreign redo information to perform recovery on the PDB clone, a DBMS managing the PDB clone maintains mapping information that maps PDB source reference information to corresponding information for the PDB clone.

CROSS-REFERENCE TO RELATED APPLICATIONS; BENEFIT CLAIM

This application claims the benefit of Provisional Appln. 62/245,937(Attorney Ref. No. 50277-4897), filed Oct. 23, 2015, the entire contentsof which is hereby incorporated by reference as if fully set forthherein, under 35 U.S.C. §119(e).

This application is related to the following applications, each of whichis incorporated by reference as if fully set forth herein:

-   -   application. Ser. No. 13/631,815, filed Sep. 28, 2012, titled        “Container Database” (Attorney Ref. No.: 50277-4026);    -   application. Ser. No. 14/202,091, filed Mar. 10, 2014, titled        “Instantaneous Unplug Of Pluggable Database From One Container        Database And Plug Into Another Container Database” (Attorney        Ref. No.: 50277-4088);    -   application. Ser. No. 15/093,506, filed Apr. 7, 2016, titled        “Migrating A Pluggable Database Between Database Server        Instances With Minimal Impact To Performance” (Attorney Ref. No.        50277-4969);    -   application Ser. No. ______, filed ______, titled “Techniques        For Keeping A Copy Of A Pluggable Database Up To Date With A        Source Pluggable Database In Read-Write Mode” (Attorney Ref. No.        50277-4971); and    -   application Ser. No. ______, filed ______, titled “Near-zero        Downtime Relocation of a Pluggable Database across Container        Databases” (Attorney Ref. No. 50277-4972).

FIELD OF THE INVENTION

The present invention relates to cloning pluggable databases, and, morespecifically, to cloning a source pluggable database while the sourcepluggable database remains in read-write mode.

BACKGROUND

Database consolidation involves distributing and sharing computingresources among multiple databases. Databases may be consolidated usinga container database management system. A consolidated database, such asa multitenant container database (CDB), includes one or more pluggabledatabases (PDBs). In a container database management system, eachpluggable database may be open or closed in the container databaseindependently from other pluggable databases.

Pluggable databases may be “plugged in” to a container database, and maybe transported between database servers and/or DBMSs. The containerdatabase may manage multiple pluggable databases and a given databaseserver instance may serve those pluggable databases from the containerdatabase. As such, a given container database allows multiple pluggabledatabases to run on the same database server and/or database serverinstance, allowing the computing resources of a single database serveror instance to be shared between multiple pluggable databases.

An application may access a pluggable database by establishing adatabase session on the container database management system for thatpluggable database, where a database session represents the connectionbetween an application and the container database management system foraccessing the pluggable database. A database session is initiated for apluggable database by, for example, transmitting a request for a newconnection to the container database management system, the requestspecifying the pluggable database. A container database managementsystem may host multiple database sessions, each database session beingfor one of multiple pluggable databases.

One of the big advantages of container database architecture is theability to provision new databases quickly. However, in order to clone aparticular source PDB, the source PDB generally needs to be in read-onlymode. In read-only mode, write operations are prohibited and, as such,the work that can be performed on the source PDB in read-only mode isseverely limited. Thus, the requirement for a source PDB to be inread-only mode throughout the potentially significant duration of acloning operation can generate similarly significant downtime for thesource PDB. For example, copying files for a terabyte-sized PDB over anetwork can take days, during which no write operations may be performedon the source PDB that is required to be in read-only mode for thecloning operation.

One way to clone a PDB is by using third party tools. More specifically,the general method to use third party tools to clone a PDB is to make ahot backup of: the PDB's data files, the data files of the root databaseof the CDB that contains the PDB, and the redo logs. Based on thisbackup, a new temporary CDB is set up with just the PDB and rootdatabase of the CDB. Users may apply the redo from the redo logs until agiven timestamp. A user may move the now-cloned PDB from that temporaryCDB and plug the PDB into the desired destination.

However, there is a lot of overhead when a PDB clone is created usingthird-party tools as described above. For example, making a PDB cloneusing third party tools requires creating a copy of a CDB's rootdatabase data files, which is not needed for proper functioning of theresulting PDB clone. As another example, such a process may involvecopying the CDB root database data file multiple times when multipleclones are required. Further, since third-party tools are not native tothe database, such tools do not have access to many optimizations thatare available natively in many databases. Also, it takes effort fordatabase administrators to configure third-party tools to enable them towork with (and clone) data from a given CDB. As such, working withthird-party tools to perform cloning operations on PDBs significantlyincreases the database provisioning costs and slows down applicationdevelopment that requires PDB cloning.

Moving a PDB between container databases presents many of the sameproblems as cloning a PDB. For example, moving the data for a PDB from asource CDB to a destination CDB can take a significant amount of time(i.e., on the order of days for very large PDBs) and it is costly tomake a PDB unavailable for the duration of moving the PDB. Also,relocating a PDB to a destination CDB can be disruptive to users thatuse data from the PDB at the source CDB.

Generally, moving the files for a PDB between container databases may beaccomplished in multiple ways, including: copying the files to anexternal hard drive and physically moving the hard drive to the locationof the destination storage; setting up an auxiliary database thatleverages replication to synchronize changes across container databases;and live migration of virtual machines from one physical server toanother. However, these solutions can be difficult to implement, and itcan be difficult to leverage optimizations that are built into databasefunctionality using these solutions.

It would be beneficial to provide a way to clone or move a PDB, wherethe cloning/moving mechanism is native to the database, and where thatmechanism eliminates the need for the PDB to be in read-only mode oroffline during the operation. Furthermore, it would be beneficial tofacilitate a smooth and automatic migration of application load, to thenew location of a moved PDB, for applications that require access to thePDB.

Furthermore, once a PDB is cloned, it is generally difficult to refreshthe PDB clone to include, in the PDB clone, changes that have occurredin the source PDB since the clone was created. Generally, in order torefresh a cloned PDB so that the cloned PDB includes the latest changesmade to the source PDB, the cloned PDB must be discarded and a new clonemust be produced from the source PDB. Such a requirement is extremelytime consuming, especially for very large source PDBs. As such, it wouldbe beneficial to allow a user to incrementally refresh a cloned PDB, toincorporate the latest changes made to the source PDB, without requiringcreation of an entirely new clone.

The approaches described in this section are approaches that could bepursued, but not necessarily approaches that have been previouslyconceived or pursued. Therefore, unless otherwise indicated, it shouldnot be assumed that any of the approaches described in this sectionqualify as prior art merely by virtue of their inclusion in thissection.

BRIEF DESCRIPTION OF THE DRAWINGS

In the drawings:

FIG. 1 is a block diagram that depicts an example network arrangementfor cloning, refreshing, and moving a pluggable database.

FIGS. 2A-2D depict example resource arrangements detailing databaseserver instances and databases.

FIG. 3 depicts a flowchart for cloning a PDB while the PDB is inread-write mode.

FIG. 4 depicts a flowchart for incrementally refreshing a clonedpluggable database.

FIG. 5 depicts a flowchart for creating a functionally-equivalent copyof a particular source PDB.

FIG. 6 depicts a flowchart for transparently forwarding connectionrequests that request new connections to a pluggable database that hasbeen moved from a source location to a destination location.

FIG. 7 is a block diagram of a computer system on which embodiments maybe implemented.

DETAILED DESCRIPTION

In the following description, for the purposes of explanation, numerousspecific details are set forth in order to provide a thoroughunderstanding of the present invention. It will be apparent, however,that the present invention may be practiced without these specificdetails. In other instances, well-known structures and devices are shownin block diagram form in order to avoid unnecessarily obscuring thepresent invention.

General Overview

Embodiments described herein create a clone of a PDB without the need tomaintain the source PDB in read-only mode. In other words, applicationsmay continue to write to a source PDB while a clone of the source PDB isbeing created, thereby minimizing the impact of the cloning operation onusers accessing the source PDB.

According to one or more embodiments, a database server instance(“instance”) implementing a database management system (DBMS) determinesthat a clone of a PDB is to be created and records an initial time stampthat marks the time at which the instance initiates creation of theclone. The PDB being cloned may be in read-write mode during any portion(or all) of creating the clone. The instance copies the source datafiles of the PDB and sends the files to a destination location. Theinstance also records another time stamp to mark the time at which thefile copy was completed.

Since write operations on the source PDB continue being processed whilethe source PDB files are being copied, the files in the PDB clone arenot consistent, or in other words, the files are not all valid as of thesame time. Because the files of the PDB clone are not consistent, someof the files in the PDB clone reflect changes made to the source PDBwhile the file copy operation was being performed and others files inthe PDB clone do not. To make the files in the PDB clone consistent, theinstance performs data recovery on the PDB clone based on redo entriesthat record changes made to the source PDB during the time it took forthe instance to copy the PDB files. This data recovery makes allchanges, to the PDB clone, that occurred to the source PDB during thecopy operation. Once the data recovery is completed, the files of thePDB clone are consistent and the PDB clone ready to be made live.

According to one or more embodiments, the redo information, on which thedata recovery is based, is foreign to the PDB clone since the redoentries were recorded for a different PDB (i.e., for the source PDB).Since the redo entries are foreign, they refer to file identifiers (andpotentially other information) for the source PDB that do not identifythe corresponding data for the PDB clone. In order to apply foreign redoinformation to perform recovery on the PDB clone, a database serverinstance managing the PDB clone maintains mapping information that mapsPDB source information (such as file identifiers and an identifier ofthe source PDB) to corresponding information for the PDB clone. Thedatabase server instance may obtain and record this mapping informationas the files are being copied to the PDB clone.

Once a PDB clone is created, it can be beneficial to incrementallyrefresh the PDB clone to include changes made to the source PDB since atime stamp, referred to herein as the “refresh reference time stamp”. Arefresh reference time stamp for a PDB clone marks the time at which thePDB clone was most recently current with its source PDB. The refreshreference time stamp is initially populated to mark the time at whichthe PDB clone was created. Once the PDB clone has been refreshed atleast once, the refresh reference time stamp marks the time at which thePDB clone was last refreshed. For example, a PDB clone that is a cloneof a particular source PDB and that serves as a testing environmentshould be refreshed periodically so that the tests being run on the PDBclone test the changes being made to the particular source PDB.

According to one or more embodiments, a PDB clone can be incrementallyrefreshed by copying those data blocks (from the source PDB to the PDBclone) that have changed since the refresh reference time stamp. Thesource PDB may be in read-write mode during any part of the time duringwhich the data blocks are being copied to the PDB clone. Since thesource PDB may change while the data blocks are being copied to the PDBclone, recovery is performed on the PDB clone once the blocks are copiedin order to make the PDB clone files consistent. This recovery is basedon redo entries recorded for the source PDB during the time it took tocopy the source data blocks to the PDB clone. Since all of the files inthe PDB clone are now current as of a time marked by the latest timestamp on the redo entries, this time stamp becomes the new refreshreference time stamp for the PDB clone.

According to further embodiments, in the context of moving a givensource PDB between container databases, creation of a PDB clone whilethe source PDB of the clone is in read-write mode (also called a “hotclone operation”) can be leveraged to minimize impact on users thatrequire access to the source PDB. More specifically, embodiments startmoving a PDB from a source CDB to a distinct destination CDB byperforming a hot clone operation to copy the files of the PDB from thesource CDB to the destination CDB.

Once the PDB clone is made at the destination CDB (including a firstround of recovery based on redo information from the source PDB to makethe files consistent), the source PDB is closed to write operations sothat changes to the source PDB cease. Then a second round of recovery isperformed on the PDB clone, which recovery is based on redo entries thatwere recorded for the source PDB after the last redo entry that wasapplied to the PDB clone in connection with the first round of recovery.

This second round of recovery applies all changes that have beenperformed on the source PDB to the PDB clone. At that point, the PDBclone at the destination CDB is a functionally-equivalent copy of thesource PDB and the PDB clone is opened for read-write operations. Thesource PDB may be removed from the source CDB once the copy of the PDBat the destination CDB is a functionally-equivalent copy. Since thesource PDB is only closed to write operations during the time it takesto prepare and perform the second round of recovery on the PDB clone,impact of moving the PDB is minimized.

According to one or more embodiments, once the PDB has been moved fromthe source CDB to the destination CDB, connection requests that requestnew connections to access the PDB at the source CDB are transparentlyforwarded to the PDB clone at the destination CDB. As such, impact ofmoving a PDB between distinct container databases, on users that requireaccess to the PDB, is minimized.

Architecture for Cloning, Refreshing, and Moving a Pluggable Database

FIG. 1 is a block diagram that depicts an example network arrangementfor cloning, refreshing, and moving a pluggable database, according toone or more embodiments. Network arrangement 100 includes a clientdevice 110 and server devices 140 and 150 communicatively coupled via anetwork 120. Example network arrangement 100 may include other devices,including client devices, server devices, storage devices, and displaydevices, according to one or more embodiments.

Client device 110 may be implemented by any type of computing devicethat is communicatively connected to network 120. Exampleimplementations of client device 110 include, without limitation,workstations, personal computers, laptop computers, personal digitalassistants (PDAs), tablet computers, cellular telephony devices such assmart phones, and any other type of computing device.

In network arrangement 100, client device 110 is configured with adatabase client 112. Database client 112 may be implemented in anynumber of ways, including as a stand-alone application running on clientdevice 110, or as a plugin to a browser running at client device 110,etc. Database client 112 may be implemented by one or more logicalmodules. Client device 110 may be configured with other mechanisms,processes and functionalities, depending upon a particularimplementation.

Network 120 may be implemented with any type of medium and/or mechanismthat facilitates the exchange of information between client device 110and any of server devices 140 and 150. Furthermore, network 120 mayfacilitate use of any type of communications protocol, and may besecured or unsecured, depending upon the requirements of a particularembodiment.

According to one or more embodiments, one or both of server devices 140and 150 implement a single-server database management system (DBMS).According to one or more embodiments, one or both of server devices 140and 150 are nodes in respective clusters of nodes managed by multi-nodeDBMSs, e.g., shared-everything cluster database environments (such asOracle Real Application Clusters (“RAC”)). (See “Oracle Real ApplicationClusters (RAC)”, An Oracle White Paper, June 2013, Oracle Database 12Cdocumentation. The afore-referenced document is incorporated byreference as if fully set forth herein.)

According to one or more embodiments, any number of nodes may be part ofa node cluster managed by a multi-node DBMS. Specifically, resourcesfrom multiple nodes in a multi-node database system can be allocated torun a particular database server's software.

Server devices 140 and 150 are implemented by any type of computingdevice that is capable of communicating with client device 110 overnetwork 120 and capable of running a database server instance. Innetwork arrangement 100, server devices 140 and 150 are configured withdatabase server instances 142 and 152, respectively.

A database server instance (or “instance”) is a server that comprises acombination of the software and allocation of resources from a node.Specifically, a server, such as a database server, is a combination ofintegrated software components and an allocation of computationalresources, such as memory, a node (i.e., a computing device), and/orprocesses on the node for executing the integrated software componentson a processor, the combination of the software and computationalresources being dedicated to performing a particular function on behalfof one or more clients (such as database client 112 on client device110).

Database server instance 142 on server device 140 maintains access toand manages data in database 160. Database server instance 152 on serverdevice 150 maintains access to and manages data in database 170.According to an embodiment, access to a given database comprises accessto a set of disk drives storing data for the database and to data blocksstored thereon. Databases 160 and 170 may variously reside in any typeof storage, including volatile and non-volatile storage, e.g., randomaccess memory (RAM), one or more hard disks, main memory, etc.

One or more of the functions attributed to processes running on serverdevice 140 and/or 150 as described herein may be performed by serviceson other server devices that are communicatively coupled to network 120.Furthermore, any of the functionality attributed to database serverinstances 142 and 152 herein may be performed by another logical entityof network arrangement 100, according to one or more embodiments. Also,database server instances 142 and 152 may each be implemented by one ormore logical modules, and are described in further detail below.

Server devices 140 and 150 are also configured with database listeners144 and 154, respectively. Database listener 144 and database listener154 each represent one or more database listeners running on therespective server devices. A database listener is part of a containerdatabase management system and is configured to listen, at a given port,for requests made to the container database management system. Serverdevices 140 and 150 may be configured with other mechanisms, processesand functionalities, depending upon a particular implementation.

In an embodiment, each of the processes and/or functionality describedin connection with database client 112, database server instances 142and 152, database listeners 144 and 154, and/or databases 160 and 170are performed automatically and may be implemented using one or morecomputer programs, other software elements, and/or digital logic in anyof a general-purpose computer or a special-purpose computer, whileperforming data retrieval, transformation, and storage operations thatinvolve interacting with and transforming the physical state of memoryof the computer.

Database Systems

Embodiments of the present invention are used in the context of databasemanagement systems (DBMSs). Therefore, a description of a DBMS isuseful. A DBMS manages a database. A DBMS may comprise one or moredatabase servers. A database comprises database data and a databasedictionary that are stored on a persistent memory mechanism, such as aset of hard disks. Database data may be stored in one or more datacontainers. Each container contains records. The data within each recordis organized into one or more fields. In relational DBMSs, the datacontainers are referred to as tables, the records are referred to asrows, and the fields are referred to as columns. In object-orienteddatabases, the data containers are referred to as object classes, therecords are referred to as objects, and the fields are referred to asattributes. Other database architectures may use other terminology.

Users may interact with an instance of a database server of a DBMS bysubmitting, to the database server instance, commands that cause thedatabase server instance to perform operations on data stored in adatabase. For example, a user at client device 110 submits, via databaseclient 112, a database server command to database server instance 142with which database client 112 maintains a connection. A user may be oneor more applications running on client device 110 that cause databaseclient 112 to interact with database server instance 142. Multipleparties may access database resources through a given application.Multiple parties and/or users may also be referred to herein,collectively, as a user.

A database command may be in the form of a database statement thatconforms to a database language. An illustrative example databaselanguage for expressing database commands is Structured Query Language(SQL). For example, data manipulation language (DML) instructions areissued to a DBMS to manage data stored within a database structure, andSELECT, INSERT, UPDATE, and DELETE are common examples of DMLinstructions found in SQL implementations.

Container Database and Pluggable Database Architecture

FIGS. 2A-2D depict example resource arrangements detailing databaseserver instances 142 and 152 and also databases 160 and 170.Specifically, in FIG. 2A, database 160 includes a root database 212 thatrepresents the data for a container database (CDB) 210. CDB 210 containspluggable databases (PDBs) 214 and 216. In a manner similar to database160, database 170 includes a root database 232 that represents the datafor a CDB 230. CDB 230 contains a PDB 234. According to one or moreembodiments, CDBs 210 and 230 may contain any number of pluggabledatabases, notwithstanding the number of pluggable databases depicted inany of FIGS. 2A-2D.

A container database, such as CDB 210, that contains multiple pluggabledatabases provides in-database virtualization for consolidating themultiple separate pluggable databases. Pluggable databases may be“plugged in” to a container database, and the container database may betransported between database servers and/or DBMSs.

Taking database 160 as an example, root database 212 is a database usedto globally manage the associated CDB 210, and to store data required tomanage access to PDBs contained in CDB 210. Although root databases 212and 232 are depicted in FIG. 2A as distinct database objects separatefrom other database objects, any architectural implementation forstoring container database data may be used within embodiments.

Database 160 also includes redo log(s) 220 and database 170 includesredo log(s) 240. Redo logs in a given database include redo informationthat represents changes that have been made to data in the correspondingdatabase. Each redo entry in the redo information that records a changemade to a pluggable database includes information identifying thepluggable database in which the change was made, whether the change wascommitted, and a time at which the change was committed (if applicable).A redo entry may include any kind of information, depending uponparticular implementations.

Pluggable Database Consistency

In order for the clone of a pluggable database to function properly, itmust be transactionally consistent. A cloned PDB is transactionallyconsistent when the PDB can be used by a database management system toexpose, to a given transaction, no uncommitted changes performed byother transactions and all committed changes performed by othertransactions. A database management system collects information neededto provide a transactionally-consistent view of a PDB in undo data. Assuch, copying the undo data (collected for a source PDB) to the data fora cloned PDB (which was created from the source PDB) allows the PDBclone to be used in a transactionally-consistent manner based on theundo data.

Another condition for a pluggable database clone to function properly is“file consistency”. For a PDB clone to have file consistency, all filesin the cloned PDB must be from the same SCN (or point in time). In otherwords, a PDB has file consistency when all changes made to the files inthe source PDB, until a given point in time, are present in the filesbelonging to a PDB. Herein, when all files in a cloned PDB are in thesame state that the source files had at a particular point in time, thefiles of the cloned PDB are said to be “consistent”.

One way to ensure file consistency is to freeze the source PDB beingcloned in read-only mode while the clone is being created. Since writeoperations are not processed on a PDB in read-only mode, the files ofthe PDB do not change while the PDB is in read-only mode. A clonecreated while a source PDB is in read-only mode is an exact copy of thesource PDB (which inherently has file consistency) and thus the files ofthe clone are also consistent.

However, depending on the size of the PDB being cloned, a cloningoperation can take a significant amount of time (on the order of daysfor very large PDBs) in order to copy all of the source PDB files to theclone. Keeping a source PDB in read-only mode for the duration of acloning operation greatly reduces the utility of the source PDB while itis being cloned since a significant percentage of the operationsperformed on a given PDB require write access to the PDB. Thus, therequirement that a PDB be in read-only mode during cloning makes cloninga costly operation.

Cloning a Pluggable Database while in Read-Write Mode

According to one or more embodiments, a PDB may be cloned while the PDBis in read-write mode where the resulting PDB clone has bothtransactional consistency and file consistency. Furthermore, cloning asource PDB in the background while users continue to have read and writeaccess to the source PDB significantly decreases/virtually eliminatesthe cost of cloning the PDB in that access to the source PDB is notrestricted during the cloning operation.

FIG. 3 depicts a flowchart 300 for cloning a source PDB while the sourcePDB is in read-write mode. At step 302, an instruction to clone, to adestination location, a particular pluggable database at a sourcelocation is received. For example, database server instance 142receives, from database client 112, an instruction to clone PDB 214 andsave the clone to CDB 210, which is the CDB in which PDB 214 resides.According to one or more embodiments, receipt of the cloninginstruction, by a database server instance, triggers performance ofsteps 304-312 of flowchart 300 such that steps 304-312 are performed inresponse to receiving the cloning instruction.

At step 304, an initial time stamp is determined, where the initial timestamp marks a time occurring before any files in the particularpluggable database are copied in connection with the receivedinstruction to clone. For example, in response to receiving the cloninginstruction, database server instance 142 determines and records aninitial time stamp that marks a time occurring before any files of PDB214 are copied in connection with carrying out the cloning instruction.

According to one or more embodiments, database server instance 142obtains a checkpoint, at the initial time stamp, for files in source PDB214. Setting this checkpoint causes all changes made to source PDB 214,until that initial timestamp, to be flushed to disk.

To illustrate, database server instance 142 records an initial timestamp that is a system change number (SCN) that marks the time at whichfile copying (as described in connection with step 306) commences (e.g.,SCN=1010). An SCN is a logical, internal time stamp used by databasessuch as databases 160 and 170. Nevertheless, an SCN is a non-limitingexample of a kind of time stamp, and any kind of time stamp may be usedwithin embodiments of the invention.

At step 306, files, included in the particular pluggable database, arecopied to the destination location to produce a copy of the particularpluggable database at the destination location. According to oneembodiment, files in the particular pluggable database are copied to thedestination location.

For example, database server instance 142 copies the files for PDB 214to a copy of PDB 214 (i.e., PDB clone 218) at another distinct locationwithin CDB 210, as depicted in FIG. 2B. Specifically, FIG. 2B depictsthe network configuration of FIG. 2A in which files for PDB 214 havebeen copied to PDB clone 218 in CDB 210. The label “PDB clone” isutilized herein for clarity in illustration of embodiments. Once a PDBclone is made available to users, the PDB clone functions in the sameway as any other PDB.

Once all of the files are copied, PDB clone 218 includes all of thefiles of PDB 214 (including a copy of undo data 214A at undo data 218A).However, according to one or more embodiments, PDB 214 is available forwrite operations (or is operated in read-write mode) during any portionor all of the copying operation. Since PDB 214 was potentially changedwhile PDB clone 218 was being created, the files of PDB clone 218 maynot yet have file consistency.

At step 308, a final time stamp is determined, where the final timestamp marks a time occurring after copying the files included in theparticular pluggable database is complete. For example, database serverinstance 142 determines and records a final SCN that marks a timeoccurring after instance 142 copies all of the files for source PDB 214to PDB clone 218. This final time stamp may mark any time after all ofthe files of source PDB 214 have been copied to the requested PDB clone218, including the time at which copying is completed. For purposes ofillustration, as a non-limiting example, the final SCN recorded byinstance 142 is SCN=1040.

At step 310, redo information that was recorded between times marked bythe initial time stamp and the final time stamp is collected frominformation for the particular pluggable database at the sourcelocation. For example, database server instance 142 retrieves, from redolog(s) 220, those redo entries that are associated with SCNs between(and according to one or more embodiments including) SCNs 1010 and 1040,which are the recorded initial and final time stamps for the cloningoperation of PDB 214.

Redo log(s) 220 may store redo entries for multiple pluggable databasestogether, or, according to implementations, may store redo entries foreach pluggable database separately from redo entries for other pluggabledatabases. According an embodiment, the retrieved redo entries includeall redo entries in redo log(s) 220 that record changes from the giventime frame for any pluggable database that was changed during that time.According another embodiment, the retrieved redo entries exclude allredo entries in redo log(s) 220 that record changes for PDBs other thanPDB 214. In other words, in this embodiment, the retrieved redo entriesinclude only those redo entries, in redo log(s) 220, that record changesfor PDB 214.

According to one or more embodiments, redo log(s) 220 include both (a)one or more online logs into which redo entries for PDB 214 are activelybeing placed; and (b) one or more archive logs that include redo entriesfor PDB 214 that have been archived.

At step 312, based, at least in part, on the redo information, recoveryis performed on the copy of the particular pluggable database. Forexample, database server instance 142 performs recovery, on all of thefiles for PDB clone 218 (including performing recovery on undo data218A), based on the retrieved redo entries. Specifically, instance 142uses the information in the retrieved redo entries to make all of thefiles in PDB clone 218 current (and consistent) as of the final SCN (orSCN=1040). According to one or more embodiments, this retrieved redoinformation, which is foreign to PDB clone 218, is made applicable toPDB clone 218 based on foreign reference identifier mapping data asdescribed below.

Performing recovery based on the retrieved redo information adjusts thefiles so that they are consistent with the files of the source PDB as ofthe final recorded time stamp. This is important because the files inthe source PDB have been changing during the copy operation, and eachfile is only guaranteed to be current as of the time it is actuallycopied. Performing recovery on the cloned PDB ensures that all of thefiles in the clone are valid as of the same point in time (i.e., thetime marked by the final time stamp).

To be clear, the source PDB may continue to be changed after the timemarked by the final time stamp. However, these changes need not bereflected in the PDB clone in order for the clone to be bothfile-consistent and transactionally-consistent.

Creating a Clone in a Distinct Container Database

While the given example illustrates creating a clone of a source PDBwithin the CDB that contains the source PDB, embodiments also createclones of a source PDB within a CDB that is distinct from the source CDBthat contains the source PDB. In these embodiments, the database serverinstance that manages the source CDB and the database server instancethat manages the destination CDB communicate any required information inorder to perform the cloning operation, e.g. via network 120.

For example, database server instance 142 receives, from database client112, an instruction to clone PDB 214 and to save the clone to CDB 230 indatabase 170, where CDB 230 is distinct from CDB 210. In response toreceiving this request, database server instance 142 determines aninitial time stamp (as described above in connection with step 304 offlowchart 300) and begins copying files from PDB 214 (in CDB 210) to aPDB clone 236 (in CDB 230) over network 120 (as described above inconnection with step 306 of flowchart 300). FIG. 2C depicts PDB clone236 (including undo data 236A) that represents the files that have beencopied from PDB 214 to CDB 230.

Database server instance 142 identifies a final time stamp that marks atime after copying the files for PDB 214 is complete (as described inconnection with step 308 of flowchart 300 above). For example, after allof the files for PDB 214 are copied to PDB clone 236, instance 142identifies a final SCN that marks the time that file copy operation iscompleted.

Database server instance 142 collects those redo entries, from redolog(s) 220, that are associated with time stamps between (and, accordingto one or more embodiments, including) the initial and final time stampsrecorded for the cloning operation (as described in connection with step310 of flowchart 300 above). Instance 142 sends the collected redoentries to database server instance 152.

Database server instance 152 performs recovery on PDB clone 236 (asdescribed in connection with step 312 of flowchart 300 above) based onthe redo entries received from database server instance 142. Accordingto one or more embodiments, this retrieved redo information, which isforeign to PDB clone 236, is made applicable to PDB clone 236 based onforeign reference identifier mapping data as described below.

Pluggable Database-Specific Undo Data

In addition to having file consistency, pluggable databases must alsohave transactional consistency. To this end, container databasesmaintain undo data for pluggable databases included therein. This undodata stores information based upon which a DBMS may roll back changes(committed or uncommitted) for data being queried by a giventransaction. Rolling back changes may be performed for a variety ofpurposes, including for consistent read purposes, for recovery purposesafter an aborted transaction, etc. For example, with reference to FIG.2A, CDB 210 stores undo data 214A for PDB 214 and undo data 216A for PDB216, and CDB 230 stores undo data 234A for PDB 234.

Generally, the undo data stored by a CDB is undo data that is shared forall of the contained PDBs. In such a scenario, the undo data for a givenPDB is not easily separable from the undo data for other PDBs in thesame CDB.

However, according to one or more embodiments, data for a given PDBincludes a dedicated tablespace (including one or more data files)storing undo data for the PDB. According to one or more embodiments, theundo data stored for a particular PDB includes only undo data for thatparticular PDB and stores undo data for no other PDB. For example, FIG.2A depicts undo data 214A included in the data for PDB 214. Because theundo data for PDB 214 is part of the PDB's data files, instance 142automatically creates redo entries (i.e., stored in redo log(s) 220) forchanges made to the undo data as part of recording redo entries for PDB214.

Furthermore, because the undo data for a PDB is part of the PDB's data,copying the data for the PDB automatically includes copying the undodata for the PDB. Once the undo data for a PDB is copied to the PDBclone, the undo data is updated, with the rest of the data for the PDB,based on the redo information (e.g., as described in connection withstep 312 of flowchart 300).

Foreign Reference Identifier Mapping Data

According to one or more embodiments, performing recovery on a clonedPDB based on redo information that was recorded for a distinct sourcePDB requires translation of references in the redo information. Morespecifically, the redo information recorded for a source PDB includesreference information (such as file identifiers/numbers, data blockidentifiers, pluggable database identifiers, etc.) that is specific tothe source PDB. This source-specific reference information does notnecessarily refer to the properly corresponding data in the cloned PDBsince the cloned PDB includes newly copied files stored within differentdata blocks (whether the destination of the PDB clone is the source CDBthat stores the source PDB, or the destination of the PDB clone is adifferent CDB than the source CDB).

To illustrate, a redo entry includes information identifying a file towhich the redo entry is applicable, such as an actual file number (AFN)that identifies a file, and a data block address (DBA) that identifies adata block within the file, etc. For example, a particular redo entryincludes foreign reference information as follows: a PDB identifier“124”, an AFN “9”, and a DBA “10”. This reference information indicatesthat the entry includes change information for a change made to thesource PDB in a data block with DBA=10 in a file, in the source PDB,with the AFN of 9.

The destination database server instance, which manages the PDB clone,creates mapping data that maps reference information that is specific tothe source PDB (referred to herein as “foreign” information) toreference information that is specific to the cloned PDB (referred toherein as “local” information). A database server instance creates theforeign reference identifier mapping data at any time, e.g., while thefiles for the source PDB are being copied to the destination location,after the files for the source PDB are copied to the destinationlocation, etc.

Application of foreign redo entries to perform recovery on a PDBrequires verification that the redo entries are being used only whenthose entries are applicable. As such, during recovery of the PDB cloneusing redo information from the source PDB, the database server instancemanaging the PDB clone translates, based on the mapping data, foreignreferences in the redo information to local references that referencethe corresponding information in the PDB clone. As previously stated,this foreign reference mapping data is required to apply foreign redoinformation whether or not the PDB clone is created in the same CDB asthe source PDB.

Continuing with the above example, the database server instance managingthe PDB clone determines, based on the mapping data, that the foreignPDB identifier “124” in the redo entry maps to the PDB identifier “236”of the PDB clone. As such, the foreign redo entry should be applied tothe data in the PDB clone. According to one or more embodiments, thedatabase server instance managing the PDB clone identifies the local PDBidentifier that is mapped to the foreign PDB identifier, in the mappingdata, once during performing recovery for the PDB clone. Afterwards, allredo entries that include the foreign PDB identifier that maps to thelocal PDB identifier of the PDB clone are used to perform recovery forthe PDB clone. The database server instance does not base recovery ofthe PDB clone on redo entries that are associated with PDB identifiersother than the foreign PDB identifier that maps to the local PDBidentifier of the PDB clone.

Continuing with the example, in order to perform recovery based on theparticular redo entry, the destination database server instance looksup, in the mapping data, the local file number that corresponds to theforeign AFN of 9. Based on the mapping data, the database serverinstance determines that the local file number corresponding to theforeign AFN of 9 is AFN=20. According to one or more embodiments, thedestination database server instance also looks up the local DBAcorresponding to the foreign DBA indicated in the redo entry to beapplied. Instance 152 performs recovery, based on the particular redoentry, at the location indicated by the local reference identifiers thatinstance 152 identified based on the mapping data.

Connecting to Access the Cloned Database

Once recovery is performed on the PDB clone, which means that all of thefiles in the PDB clone are current as of the same point in time, thecloned PDB is made available to users. For example, when the files ofPDB clone 218 have been updated based on the retrieved redo information,as described in connection with step 312 of flowchart 300, databaseserver instance 142 registers, with a connection manager, informationindicating that PDB clone 218 is available for new connections. Forexample, the connection manager manages one or more connection pools forone or more applications that require access to pluggable databases inCDB 210. When the connection manager receives a request for a newconnection to access PDB clone 218, and in the absence of anypreviously-established connections for accessing PDB clone 218 that maybe utilized to fulfill the request, the connection manager initiates anew connection for accessing PDB clone 218, i.e., via database serverinstance 142.

One or more users may utilize the established connection to query datain PDB clone 218. According to one or more embodiments, undo data 218Ais used according to the normal course of database functioning to rollback committed and/or uncommitted changes made to data in PDB clone 218for a variety of purposes including consistent read for data requestedby queries, etc. Undo data 218A includes information about transactionsthat were committed or aborted at the source PDB of PDB clone 218. Whena query over PDB clone 218 refers to data that was changed by atransaction that was aborted at the source PDB of PDB clone 218, themanaging database server instance consults the transaction tableincluded in undo data 218A, and upon detecting that the data was changedby an uncommitted transaction, performs rollback of the changes causedby the aborted transaction.

Refreshable Pluggable Database Copy

Many times, users need to update a clone of a pluggable database inorder to incorporate, in the cloned pluggable database, the latestchanges made to the clone's source pluggable database. For example, auser produces a clone of a particular PDB, which represents a productionand test environment. After the clone is created, the source PDB (thatis the source of the cloned PDB) continues processing write operations,i.e., operating in read-write mode. After a certain amount of time, itwould be beneficial for the cloned PDB to incorporate any changes madeto the source PDB since the clone was created so that the clone, whichis acting as a production and test environment, is up-to-date.

Generally, in order to update a cloned PDB to include all changes madeto the clone's source PDB, the clone must be regenerated based on thenewest version of the source PDB. However, it is costly to produce newclones of pluggable databases on a regular basis (e.g., every day, everyhour, etc.) as would be desirable from the standpoint of data recency inmany situations.

According to one or more embodiments, a user may incrementally refresh acloned PDB, which causes the PDB clone to incorporate changes made tothe clone's source PDB without regenerating the PDB clone in itsentirety. Furthermore, the cloned PDB may be refreshed while the sourcePDB is in read-write mode. According to one or more embodiments,incrementally refreshing a PDB clone involves copying, to the PDB clonedata, only those portions of the source PDB that have been changed so asto minimize processing time for incrementally refreshing the cloned PDB.

FIG. 4 depicts a flowchart 400 for incrementally refreshing a clonedpluggable database. At step 402, an instruction to refresh a cloneddatabase based on a source database is detected. According to one ormore embodiments, the cloned and source databases are pluggabledatabases. According to further embodiments, the cloned and sourcedatabases are any kind of database that is able to be cloned.Non-limiting examples are provided herein that illustrate embodiments inthe context of pluggable databases.

To illustrate step 402, database server instance 152 detects aninstruction to refresh a cloned database when instance 152 receives,from database client 112, an instruction to refresh PDB clone 236 in CDB230, which is a clone of source PDB 214 in CDB 210 (as depicted in FIG.2C).

As another example, previous to detecting an instruction to refresh acloned database, database server instance 152 receives an instruction toautomatically refresh PDB clone 236 at regular time intervals (e.g.,every 24 hours, every 30 minutes, etc.). According to one embodiment, adefinition of the regular time intervals is provided in connection withthe instruction to automatically refresh the PDB clone, i.e., as aparameter to the instruction. According to another embodiment, thedefinition of the regular time interval is a default regular timeinterval definition that is accessible by instance 152. In this example,instance 152 detects an implied instruction to refresh PDB clone 236when the time to refresh PDB clone 236 has arrived, as indicated by thepreviously-received instruction to automatically refresh the PDB cloneat regular time intervals.

In order to refresh a PDB clone, the database server instance must beable to identify the source PDB of the PDB clone. According to anembodiment, the received instruction includes a reference to a sourcePDB based on which to perform the refresh operation for the indicatedPDB clone. According to another embodiment, the PDB clone includes areference to the source PDB based on which the PDB clone was originallycopied. For example, since PDB clone 236 was originally created bycopying PDB 214, PDB clone 236 includes a reference to PDB 214identifying that pluggable database as the source of PDB clone 236.

According to one or more embodiments, a PDB clone may be created as arefreshable PDB clone. A refreshable PDB clone includes, in addition toother information that is generally required for a PDB clone,information that facilitates the incremental refresh of the clone. Forexample, a refreshable PDB clone includes one or more of the followinginformation that facilitates incremental refresh: a refresh referencetime stamp, mapping data that maps foreign reference information in thesource PDB to local reference information in the PDB clone, informationidentifying the source PDB of the PDB clone, information required tocontact a database server instance that manages the source PDB of thePDB clone, etc.

According to one or more embodiments, detecting the refresh instructiontriggers refresh of the PDB clone. In other words, steps 404-414 offlowchart 400 are triggered by a database server instance detecting therefresh instruction such that steps 404-414 are performed in response tothe database server instance detecting the refresh instruction.

Preparing a PDB Clone for Refresh

According to one or more embodiments, a refreshable PDB clone, such asPDB clone 236, is operated in read-write mode. In other words, after acloning operation, the data in the refreshable PDB clone diverges fromthe data in the PDB clone's source PDB. However, in order to refresh thePDB clone, the data in the clone must not be divergent from the sourcePDB data. In other words, the PDB clone data must be in a state in whichthe source PDB data existed at one point in time. If the PDB clone doesnot diverge from the source PDB, it is possible to apply, to the clone,those changes that have occurred in the source PDB since that point intime, in order to bring the cloned PDB up-to-date with the source PDB.

When a refreshable PDB clone has been operating in read-write mode, thePDB clone is rolled back to a state at which the PDB clone data was notdivergent from the source PDB data. To illustrate, continuing with theexample described in connection with step 402 of flowchart 400, PDBclone 236 operates in read-write mode and one or more changes are madeto the data of PDB clone 236 that cause PDB clone 236 to diverge fromthe data in source PDB 214. Detecting the refresh instruction triggersdatabase server instance 152 to determine whether one or more changeshave been made to PDB clone 236 since a time marked by a refreshreference time stamp such that determining whether one or more changeshave been made to the PDB clone is performed in response to detectingthe refresh instruction.

A refresh reference time stamp marks a time at which PDB clone 236reflected the data of source PDB 214 without divergent changes. Forexample, the refresh reference time stamp for PDB clone 236 marks thetime at which PDB clone 236 was created from source PDB 214. Accordingto one or more embodiments, a refreshable PDB clone stores the latestapplicable refresh reference time stamp in its data store.

In response to database server instance 152 determining that one or morechanges have been made to PDB clone 236 since a time marked by a refreshreference time stamp, i.e., because PDB clone 236 has been operating inread-write mode since the time marked by the refresh reference timestamp and has processed one or more write operations on the data for PDBclone 236, database server instance 152 rewinds the state of the data inPDB clone 236 back to the state in which PDB clone 236 existed at thetime marked by the refresh reference time stamp.

Database server instance 152 may revert the state of the data in PDBclone 236 back to the state in which it existed at a given point in timein a variety of ways. To illustrate, database server instance 152establishes a restore point for PDB clone 236 that marks the state ofthe data in PDB clone 236 at the time indicated by the refresh referencetime stamp. Database server instance 152 performs a flashback on thedata in PDB clone 236 based on the restore point. As a furtherillustration, database server instance 152 performs a point-in-timerecovery for the data in PDB clone 236 based on such a restore point,etc.

Copying Changed Data Blocks from the Source PDB to the Cloned PDB

Returning to the discussion of flowchart 400 (FIG. 4), at step 404, aset of data blocks, in the source database that have changed since atime marked by a refresh reference time stamp, are identified. Accordingto one or more embodiments, a refreshable PDB clone includes informationrequired to connect to the database server instance (or “sourceinstance”) that manages the clone's source PDB. For example, when therefreshable PDB clone is created, the user specifies a database link inthe SQL statement that creates the clone, which link can be used toconnect to the clone's source PDB. Using that information, the databaseserver instance that manages the PDB clone (or “destination instance”)contacts the source instance to request the set of data blocks, in thesource PDB, that have changed since the time marked by a refreshreference time stamp of the PDB clone.

For example, PDB clone 236 includes information needed for databaseserver instance 152 to communicate with database server instance 142.Using that information, database server instance 152 requests, fromdatabase server instance 142, the set of data blocks in PDB 214 thathave changed since a time indicated by the refresh reference time stampthat is recorded in PDB clone 236. According to an embodiment, instance152 includes, in the request, at least an identifier of PDB 214 and therefresh reference time stamp.

In response to receiving the request for the set of data blocks,database server instance 142 identifies the set of blocks in source PDB214 that have changed since the time indicated in the refresh referencetime stamp. According to an embodiment, instance 142 maintains changeinformation indicating times at which data blocks in PDB 214 have beenchanged. Instance 142 determines, based on the change information, theset of data blocks to return as a response to the request for the set ofdata blocks by identifying those data blocks that are associated withchange time stamps, in the change information, that mark times thatoccur after the time marked by the refresh reference time stamp.

According to another embodiment, instance 142 performs a comparisonbetween source PDB 214 and PDB clone 236 to identify those data blocksthat are different between source PDB 214 and PDB clone 236. In such anembodiment, PDB clone 236 need not be rewound to eliminate divergence ofthe clone from the clone's source data since the comparison betweenpluggable databases would inherently identify any data block in the PDBclone that is different from a corresponding data block in the sourcePDB no matter the cause of the change.

Database server instance 142 sends, to instance 152 as a response to therequest for the set of data blocks, only those data blocks in PDB 214that are identified as different than the data blocks in PDB clone 236.The data blocks may be sent all at once or may be sent in groups of oneor more blocks over a period of time.

At step 406, a starting time stamp is determined, where the startingtime stamp marks a time occurring before copying any blocks, from theset of data blocks, into data for the cloned database. For example,database server instance 142 records, as the starting time stamp, a timestamp that marks the time at which instance 142 receives, from instance152, the request for the set of changed data blocks. As another example,database server instance 142 records, as the starting time stamp, a timestamp that marks the time at which database server instance 142initiates gathering and sending data blocks to instance 152 to fill therequest for the set of changed data blocks.

At step 408, the set of data blocks are copied from the source databaseinto data for the cloned database. For example, database server instance152 receives, from database server instance 142, changed data blocksfrom source PDB 214, and database server instance 152 saves those datablocks to the data for PDB clone 236. In order to save the data blocksto PDB clone 236, instance 152 identifies corresponding data blockswithin PDB clone 236 that correspond to the data blocks being receivedand instance 152 replaces the data blocks in PDB clone 236 with thecorresponding received data blocks from PDB 214.

In order to identify data blocks from source PDB 214 that correspond tothe data blocks from PDB clone 236, database server instance 152utilizes foreign reference mapping data that maps foreign referenceidentifiers for source PDB 214 (such as file numbers and block numbers)to corresponding local reference identifiers for PDB clone 236, whichmapping data is described in further detail above. PDB clone 236 issaved as a refreshable PDB clone, and, as such, database server instance152 creates the foreign reference mapping data when PDB clone 236 iscreated for use in connection with PDB clone refresh operations.

For each data block in the set of source PDB data blocks, databaseserver instance 152 identifies a data block in PDB clone 236 thatcorresponds to the source PDB data block based on the foreign referencemapping data. Instance 152 then replaces each identified data block inPDB clone 236 with the corresponding source PDB data block.

At step 410, a final time stamp is determined, which final time stampmarks a time occurring after copying the set of data blocks is complete.For example, database server instance 142 identifies, as the final timestamp, a time stamp that marks the time at which instance 152 finishesreplacing each identified data block in PDB clone 236 with thecorresponding source PDB data block. As another example, database serverinstance 142 identifies, as the final time stamp, a time stamp thatmarks the time at which database server instance 142 finishes sendingthe data blocks to instance 152.

Refreshing the Cloned Database Based on Redo Information from the SourceDatabase

According to one or more embodiments, copying the set of data blocks isperformed, at least partially, while the source database is inread-write mode. For example, while instance 142 gathers and sendsinformation for the set of data blocks, in source PDB 214, that havechanged since the time marked by the refresh reference time stamp(referred to herein as the “block copy operation”), source PDB 214 isopen to write operations. Therefore, it is possible that one or morewrite operations have changed data in source PDB 214 during the time ittook to complete the block copy operation.

As such, once all of the data blocks from source PDB 214 are stored tothe data of PDB clone 236, PDB clone 236 has been updated, but it ispossible that not all of the data blocks are current as of the samepoint in time (i.e., PDB clone 236 is potentially lacking fileconsistency). In order to ensure that the files in PDB clone 236 arecurrent as of the same time, any changes that were made to source PDB214 while instance 142 was performing the block copy operation must beapplied to PDB clone 236. Accordingly, as described in connection withstep 412 and 414, recovery is performed on PDB clone 236 based on redoinformation recorded for source PDB 214 such that PDB clone 236 is madefile-consistent as of a particular point in time.

At step 412, redo information, that was recorded between times marked bythe starting time stamp and the final time stamp, is collected frominformation for the source database. For example, database serverinstance 142 collects, from redo log(s) 220 those redo entries that areassociated with time stamps that mark times between times marked by thestarting time stamp and the final time stamp identified by instance 142as described in connection with steps 406 and 410.

According an embodiment, the retrieved redo entries include all redoentries in redo log(s) 220 that record changes from the given timeframe, including redo entries that are applicable to PDBs other than PDB214. According to another embodiment, the retrieved redo entries excludeall redo entries in redo log(s) 220 that record changes for PDBs otherthan PDB 214. In other words, in this embodiment, the retrieved redoentries include only those redo entries, in redo log(s) 220, that recordchanges for PDB 214.

At step 414, based, at least in part, on the redo information, recoveryis performed on the cloned database. For example, database serverinstance 142 sends, to database server instance 152, the redoinformation collected as described in connection with step 410. In turn,instance 152 performs recovery, on the files for PDB clone 236(including undo data 236A), based on the retrieved redo entries.Specifically, instance 152 applies the changes indicated in theretrieved redo entries to PDB clone 236, which makes all of the files inPDB clone 236 current as of the final time stamp recorded by instance142. According to one or more embodiments, this final time stamp is madethe new refresh reference time stamp for PDB clone 236.

As described above, and according to one or more embodiments, performingrecovery on PDB clone 236 based on redo information recorded for sourcePDB 214 requires reference translation based on foreign referencemapping data stored by instance 152. Using this mapping data, instance152 translates reference information, in the retrieved redo entries,from foreign references (relative to source PDB 214) to local references(relative to PDB clone 236). The redo information is applied to PDBclone 236 using the translated local references.

Online Relocation of a Pluggable Database Between Container Databases

At times, a pluggable database needs to be relocated from one containerdatabase to another distinct container database. The relocated pluggabledatabase must include all changes that have been successfully committedin the source pluggable database, since, after relocation, the pluggabledatabase will no longer exist at the source location. When cloning aparticular source pluggable database, the pluggable database clone neverneeds to fully catch up to the source pluggable database since thepluggable database clone only reflects a consistent view of the datafrom the source at a given point in time and, as such, the sourcepluggable database never need be closed to write operations (asdescribed above). In contrast, when a pluggable database is relocated,the pluggable database must be made unavailable to operations for someamount of time in order to allow the copy of the pluggable database toreflect all changes successfully made to the source pluggable database.

It is not desirable to make a pluggable database unavailable tooperations for any significant amount of time. However, depending on thesize of the pluggable database, a pluggable database relocation can takea significant amount of time, sometimes days. If the source containerdatabases and the destination container database (for a relocatingpluggable database) do not share storage, then relocating a pluggabledatabase involves physically moving the database files. The destinationcontainer database of the pluggable database may be in a different datacenter, and even a different geographic region than the source containerdatabase.

To illustrate, a client may want to move a locally-hosted terabyte-sizedpluggable database to a cloud hosting service, which requires moving themyriad of files for the pluggable database from a local hosting facilityin Austin, Tex. to a facility that hosts the cloud information in SaltLake City, Utah. It could take days to copy the files for the pluggabledatabase over a network to the destination CDB, and it could potentiallytake days to copy the files for the pluggable database to an externalhard drive and physically transport the files to the destinationfacility for upload to the destination CDB. Because of the amount oftime it can take to move the files of a source pluggable database, itcan be very costly to limit the availability of the source pluggabledatabase while the files are being moved.

In order to maximize the availability of a pluggable database while thepluggable database is being moved between container databases, afunctionally-equivalent copy of the pluggable database is created (e.g.,at the destination CDB). During the majority of such a copy operation,the pluggable database is available for read and write access. Afunctionally-equivalent copy of a source PDB is a copy of the source PDBthat reflects all changes that have been performed to the source PDB. Afunctionally-equivalent copy of a source PDB may be an exact copy of thesource PDB, or may be a copy of the source PDB that, when queried, (a)functions in essentially the same way that the source PDB would functionand (b) returns the same data that the same query on the source PDBwould return.

As such, FIG. 5 depicts a flowchart 500 for creating afunctionally-equivalent copy of a particular source PDB. According to anembodiment, the steps of flowchart 500 are triggered by receiving aninstruction to create a functionally-equivalent copy of the source PDBsuch that the steps of flowchart 500 are performed in response toreceiving an instruction to create a functionally-equivalent copy of thesource PDB. The functionally-equivalent copy may be located in the sameCDB as the source PDB. According to another embodiment, the steps offlowchart 500 are triggered by receiving an instruction to move thesource pluggable database from a source CDB to a destination CDB, sincecreating a functionally-equivalent copy is a part of moving a PDBbetween CDBs, as described in further detail below. When the steps offlowchart 500 are triggered by receiving the instruction to move thePDB, the steps of flowchart 500 are performed in response to receivingthe instruction to move the PDB.

Creating a functionally-equivalent copy of a source pluggable database,according to the steps of flowchart 500, is performed such that writeoperations, on the pluggable database at the source CDB, may continue tobe processed during the majority of the copy operation (i.e., duringsteps 502-510 that occur prior to the step of closing the source PDB towrite operations). In this manner, embodiments impose limitedavailability on the pluggable database data for a relatively smallamount of time, i.e., since steps 512-516 of flowchart 500 (during whichavailability of the pluggable database is limited) take a small amountof time relative to the amount of time it takes to perform steps 502-510of flowchart 500.

According to one or more embodiments, certain elements of flowchart 500are substantially similar to certain corresponding elements of flowchart300. According to one or more embodiments, inasmuch as a given elementof flowchart 500 is similar to an element of flowchart 300, descriptiongiven in connection with the element of flowchart 300 is applicable tothe corresponding element of flowchart 500. Likewise, according to oneor more embodiments, inasmuch as a given element of flowchart 300 issimilar to an element of flowchart 500, description given in connectionwith the element of flowchart 500 is applicable to the correspondingelement of flowchart 300.

At step 502 of flowchart 500, an initial time stamp is determined, wherethe initial time stamp marks a time occurring before copying any filesin the source pluggable database. For example, database server instance142 detects the need to create a functionally-equivalent copy of PDB 214(located in CDB 210) with a destination location of CDB 230. This is anon-limiting example in that a functionally-equivalent copy may be madewithin the same CDB or within a CDB that is distinct from the source CDBin which the source PDB resides. In connection with creating thefunctionally-equivalent copy, instance 142 determines and records aninitial time stamp that marks a time occurring before any files arecopied in connection with creating the functionally-equivalent copy ofPDB 214. For example, instance 142 identifies a time stamp that marksthe time at which instance 142 detects the need to create afunctionally-equivalent copy of PDB 214 as the initial time stamp.

At step 504, files included in the source pluggable database are copiedto a destination location to produce a copy of the source pluggabledatabase at the destination location. For example, database serverinstance 142 creates copies of the files of PDB 214 and causes the filecopies to be sent to database server instance 152 (which manages thedestination location, i.e., CDB 230). According to an embodiment, thecopies are created and then sent to the destination location via anetwork. According to an alternative embodiment, in the case where thedestination location shares storage with the source location of thesource PDB, the copies are performed directly from the source locationto the destination location.

Database server instance 152 receives the copies of the files of sourcePDB 214 and saves the file copies to PDB clone 236 (as depicted in FIG.2C). According to one or more embodiments, PDB 214 is operated inread-write mode during at least a portion (if not all) of the timeduring which files from PDB 214 are copied.

At step 506, a first final time stamp is determined, where the firstfinal time stamp marks a time occurring after copying the files includedin the source pluggable database is complete. For example, databaseserver instance 142 determines and records a first final time stamp thatmarks a time occurring after instance 142 finishes copying all of thefiles for PDB 214. This time stamp may mark any time after all of thefiles of the source PDB have been copied for the functionally-equivalentcopy as described in connection with step 504.

At step 508, first redo information that was recorded between timesmarked by the initial time stamp and the first final time stamp arecollected from information for the source pluggable database. Forexample, database server instance 142 retrieves, from redo log(s) 220, afirst batch of redo entries that are associated with time stamps thatmark times between the identified initial time stamp and first finaltime stamp. The retrieved redo entries at least include entriesindicating changes made to PDB 214 during the indicated time period.

At step 510, first recovery is performed on the copy of the sourcepluggable database based, at least in part, on the first redoinformation. For example, database server instance 142 sends the firstbatch of redo information indicating changes made to source PDB 214 todatabase server instance 152. Instance 152 then performs a first roundof recovery, on all of the files for PDB clone 236 (including undo data236A), based on the retrieved redo entries in the first redoinformation. Since the redo information was recorded for PDB 214 and notfor PDB clone 236, application of the redo information for PDB clone 236involves translating reference information in the redo information basedon foreign reference mapping data as described in detail above. Thisrecovery operation makes all of the files in PDB clone 236 current as ofthe first final time stamp.

At this point, PDB clone 236 is consistent transactionally (because ofundo data 236A that includes information about rolling back uncommittedchanges) and is file-consistent as of the first final time stamp.However, according to one or more embodiments, PDB 214 may be availableto receive and process write requests during any portion (or all of)steps 502-510 of flowchart 500, which means that it is possible that thedata in PDB 214 has changed from the data now in PDB clone 236.

In order to make PDB clone 236 functionally equivalent with source PDB214, PDB 214 is closed to write operations and PDB clone 236 is caughtup to the current state of PDB 214. If PDB 214 were to remain open to,and continue processing, write operations, it may not be possible tocatch PDB clone 236 up to the state of PDB 214 since the data of PDB 214would have the potential to be continually changing.

As such, at step 512 of flowchart 500, the source pluggable database isclosed to write operations at a particular point in time afterperforming the first recovery on the copy of the source pluggabledatabase. For example, in response to completing performance of thefirst round of recovery on PDB clone 236, database server instance 152sends a message to database server instance 142 indicating that instance142 should stop processing write operations on PDB 214. In response toreceiving the message, instance 142 stops further write operations frombeing performed on source PDB 214.

Instance 142 may stop further write operations from being performed onsource PDB 214 in a variety of ways. According to an embodiment,instance 142 stops further write operations from being performed onsource PDB 214 by preventing any new queries from performing writeoperations within source PDB 214 while allowing transactions (thatinclude write operations) that have already initiated to finishprocessing. In this embodiment, the write operations on PDB 214 areconsidered stopped when the last transaction that includes writeoperations over data in PDB 214 terminates and the only remainingactivity within PDB 214 is read-only activity.

According to another embodiment, instead of allowing transactions thatare performing write operations to complete processing, instance 142causes PDB 214 to be run in read-only mode and, upon switching PDB 214from read-write mode to read-only mode, transactions processing data inPDB 214 are no longer allowed to perform write operations. As such, oncePDB 214 is switched to read-only mode, transactions that are currentlyprocessing data in PDB 214 will receive errors in response to attemptingperformance of write operations in PDB 214. In this embodiment, thewrite operations on PDB 214 are considered stopped when PDB 214 isswitched to read-only mode.

According to an embodiment, instance 142 records the particular point intime at which write operations are stopped in PDB 214. This informationis used in determining what redo information should be gathered for thesecond round of recovery to be performed on the PDB clone, as describedin further detail in connection with steps 514 and 516 below.

Specifically, at step 514 of flowchart 500, second redo information,that was recorded between times marked by the first final time stamp anda second final time stamp that marks the particular point in time, iscollected from information for the source pluggable database. As such,the second redo information represents those changes that (a) wererecorded for the source PDB up until the source PDB was closed to writeoperations, and (b) have not yet been applied to the PDB clone.

To illustrate step 514, database server instance 142 retrieves, fromredo log(s) 220, a second batch of redo entries, where the redo entriesin the second batch are associated with time stamps that mark timesbetween (and according to one or more embodiments including) (a) thefirst final time stamp that marks the most recent change that wasapplied to PDB clone 236 in the first round of recovery and (b) the timeat which instance 142 stopped write operations for source PDB 214. Thus,the second redo information includes those redo entries recorded for PDB214 that represent all changes made to PDB 214 that are not yetreflected in PDB clone 236.

In an embodiment, instance 142 retrieves, from redo log(s) 220, onlythose redo entries that were recorded for source PDB 214. For example,redo log(s) 220 stores data for PDB 214 in a tablespace dedicated toredo entries for PDB 214, and instance 142 retrieves the second redoinformation from this tablespace. In this embodiment, there is no needto record a second final time stamp for use in querying redo log(s) 220for the second redo information since no redo entries included in thededicated tablespace would be associated with time stamps that marktimes occurring after write operations were stopped for PDB 214. Assuch, the second final time stamp referred to in step 514 would beinherent in the data recorded in the dedicated tablespace in redo log(s)220.

At step 516, based, at least in part, on the second redo information,second recovery is performed on the copy of the source pluggabledatabase. For example, database server instance 142 sends, to databaseserver instance 152, the second batch of redo entries described inconnection with step 514. Database server instance 152 performs a secondrecovery operation on PDB clone 236 based on the second redo informationfor PDB 214. According to one or more embodiments, the foreign referenceinformation in the second redo information is translated to localreference information based on foreign reference mapping data, asdescribed in detail above. This second round of recovery makes PDB clone236 a functionally-equivalent copy of source PDB 214, and, as such, PDBclone 236 reflects all changes that have been made to PDB 214 up to thecurrent time.

Moving a PDB from a Source CDB to a Destination CDB Using aFunctionally-Equivalent Copy

Flowchart 500 describes a process for producing afunctionally-equivalent copy of a PDB. Creating afunctionally-equivalent copy is particularly useful in connection withmoving a PDB between distinct container databases. Thus, according to anembodiment, an instruction is received, where the instruction is tomove, to a destination container database, a source pluggable databasethat is currently at a source container database. The destinationcontainer database is distinct from the source container database whenthe source container database is managed separately from the destinationcontainer database and the two container databases do not share storage.

As an example of an instruction to move a PDB between CDBs, databaseserver instance 142 (in a database configuration as depicted in FIG. 2A)receives an instruction to move PDB 214 from CDB 210 to CDB 230. CDB 210is distinct from CDB 230 in that CDB 210 is maintained separately from(and/or does not share resources with) CDB 230. According to one or moreembodiments, receiving the instruction to move the pluggable databasetriggers creating a functionally-equivalent copy of PDB 214 on CDB 230(as described in connection with flowchart 500 and depicted in FIG. 2C)such that creating a functionally-equivalent copy of PDB 214 on CDB 230is performed in response to receiving the instruction to move thepluggable database.

Migrating Connections to the PDB Functionally-Equivalent Copy in theDestination CDB

Migrating connections from a source PDB to a functionally-equivalentcopy of the source PDB at the destination CDB should be managed in orderto minimize issues such as logon storms and periods of time where thePDB is not available for connections at all. Herein, a connection to aPDB, or a connection for accessing a PDB, is a connection to a databasesession configured for accessing the PDB. At times, afunctionally-equivalent copy of the source PDB is referred to herein asan “FE copy”.

When a particular pluggable database is being moved from a source CDB toa destination CDB, in order to provide as much time as possible forconnections to migrate from the particular PDB (which is slated to betaken offline) at the source CDB to the clone of the particular PDB atthe destination CDB, embodiments open the PDB clone (which may representa functionally-equivalent copy of the particular PDB) at the destinationCDB to new connections as soon as possible. According to one or moreembodiments, a connections migrates from a first CDB to a second CDBwhen a connection to the first CDB is terminated and a new connection isinitiated with the second CDB, where the new connection to the secondCDB is used in place of the connection with the first CDB.

Thus, according to one or more embodiments, once the first round ofrecovery (as described in step 510 of flowchart 500) has been performedon the PDB clone at the destination CDB, the PDB clone is configured toaccept connections and process transactions in read-only mode. Openingthe PDB clone up to accept connection requests initiates migration ofconnections from the source PDB to the PDB clone (before the PDB cloneis an FE copy).

According to one embodiment, the instance that manages the PDB cloneimmediately processes queries issued through such connections. In thisembodiment, because the first round of recovery is insufficient to makethe PDB clone functionally-equivalent to the source PDB, queries runningon the PDB clone prior to finishing the second round of recovery willprovide information that is behind the data in the source PDB (“staledata”). However, at times, the possibility of users receiving staleinformation from the PDB clone is balanced by the benefit of providingearly access to data within the PDB clone.

However, at times, returning stale data in query results is notacceptable. In such situations, and according to another embodiment, theinstance that manages the PDB clone does not process queries over thePDB clone before the second round of recovery is complete. In thisembodiment, queries issued over connections to the PDB clone that arereceived prior to completion of the second round of recovery are placedon hold (as described herein) until the second round of recovery iscomplete. Once the second round of recovery is complete (and the PDBclone is now a PDB FE copy), the instance processes the issued queriesover the fully-updated PDB FE copy.

To illustrate making the PDB clone available for new connections, afterthe first round of recovery is performed on PDB clone 236, instance 152registers connection information for PDB clone 236 with databaselistener 154. This registration information allows database listener 154to process user requests for connections to PDB clone 236. A databaselistener is a process that runs on a server device, and may be part of aconnection manager, as described above. A database listener receivesincoming client connection requests and manages the traffic of thoserequests. After receiving the registration information, databaselistener 154 receives one or more requests for connections to PDB clone236 and, in response, provides connections to PDB clone 236. Databaseserver instance 152 begins processing read operations, received viathose connections, on PDB clone 236.

While PDB clone 236 is in read-only mode, any attempts to perform awrite operation on the PDB clone cannot be processed. Generally, writerequests on a PDB in read-only mode would result in an error beingreturned to the requester of the write operation. According to one ormore embodiments, instead of returning an error when a user attemptsperformance of a write operation on PDB clone 236 while the clone is inread-only mode, database server instance 152 puts the write operation onhold until PDB clone 236 is available to process write operations.According to an embodiment, instance 152 puts an operation on hold byplacing a database session, to which a request for the operation wasissued, in an intermediate or “sleep” mode and not responding to theoperation request (either by processing the operation or by returning anerror message) while the session is in sleep mode. Once a given type ofoperation is able to be processed over PDB clone 236, instance 152cycles through all sessions that are in sleep mode because of requestoperations of that type and instance 152 removes these sessions fromsleep mode (unless there is an additional reason why the session is insleep mode). Once the session is removed from sleep mode, instance 152processes the operations requested via the database session as if therequests were just received.

Closing Connections at the Source Pluggable Database

Because the data in PDB 214 is being moved away from CDB 210, theconnections to PDB 214 in CDB 210 are closed. According to one or moreembodiments, database server instance 142 gradually closes theconnections to PDB 214 over a period of time to allow the users of thoseconnections to gradually request new connections with PDB clone 236 atthe destination location. If database server instance 142 were toterminate all connections to PDB 214 at once (or over a very shortperiod of time) the users of those terminated connections would submitnew connection requests to PDB clone 236 at substantially the same timecausing an undesirable “logon storm”. Given that allocating a newconnection to a PDB is an expensive task, processing a wave of newconnection requests for PDB clone 236 would tax the resources ofdatabase server instance 152 and potentially degrade service performedby that instance.

According to an embodiment, once PDB 214 (operating in read-only mode)is closed to new connection requests, instance 142 begins closingpreviously-established connections to PDB 214. According to anotherembodiment, instance 142 begins closing connections to PDB 214(operating in read-only mode) in response to instance 142 receiving amessage, from instance 152, indicating that PDB clone 236 has beenplaced in read-write mode.

To avoid occurrence of a logon storm, instance 142 gradually closes theconnections to PDB 214. According to one or more embodiments, instance142 closes the connections to PDB 214 based on a particular closurerate. The closure rate at which instance 142 closes connections to PDB214 may be a default rate, may be based on information received from auser that defines a connection closure rate, or may be calculated basedon information about PDB 214 (such as a number of connections that arecurrently open with PDB 214, etc.).

According to an embodiment, database server instance 142 identifies theconnection closure rate in data for the command to move PDB 214. Forexample, the connection closure rate is provided, by the database user,as an argument to the command. To illustrate, a user indicates, via anargument to the instruction to move PDB 214, that the connections to PDB214 should all be closed in ten minutes from the time that instance 142initiates closure of the connections to PDB 214. Based on the number ofconnections to PDB 214, database server instance 142 calculates aconnection closure rate such that, when connections are closed at thecalculated rate, all connections are closed within the given amount oftime.

According to another embodiment, the connection closure rate is adefault rate of connection closures, information for which is accessibleby database server instance 142. The connection closure rate may be inthe form of an amount of time over which PDB connections should beclosed, or in the form of a rate of connections per unit time at whichPDB connections should be closed.

According to another embodiment, instance 142 automatically determinesthe connection closure rate based, at least in part, on statisticsmaintained for at least one of: the source PDB 214, PDB clone 236,database 160, database 170, CDB 210, CDB 230, instance 142, or instance152. For example, these statistics comprise one or more of: a historicalrate of connection initiation requests for PDB clone 236; the number ofconnections to PDB 214 maintained by instance 142 at the time that theinstruction to move PDB 214 is received; the size of the data stored forPDB 214 in CDB 210; a rate of query execution on the instance 152; oneor more transaction rates for PDB 214 at instance 142 or for PDB clone236 at instance 152; a measure of processing power of database serverinstance 152; etc.

For example, instance 142 calculates the connection closure rate basedon the rate of transactions for PDB 214 processed by instance 142.Calculation of the connection closure rate may be based on mapping datathat maps closure rates to set thresholds for transaction rates.According to one or more embodiments, based on the mapping data,instance 142 causes connection closures to be performed more quicklywhen there is a lower transaction rate for the source PDB at the sourceinstance.

To illustrate, instance 142 determines that the rate of transactions forPDB 214 (i.e., at instance 142) is below a first threshold (e.g., wherethe first threshold is one transaction per second). In response,instance 142 sets the connection closure rate, for closing connectionsto PDB 214, at a closure rate that is mapped, in mapping data, totransaction rates less than the first threshold (e.g., closing tenconnections per minute).

As a further illustration, instance 142 determines that the rate oftransactions for PDB 214 in instance 142 is above the first thresholdand below a second threshold (that is higher than the first threshold,e.g., where the second threshold is five transactions per second). Inresponse, instance 142 sets the connection closure rate, for closingconnections to PDB 214, at a closure rate that is mapped, in mappingdata, to transaction rates greater than the first threshold and lessthan the second threshold (e.g., closing six connections per minute).

As yet further illustration, instance 142 determines that rate oftransactions for PDB 214 in instance 142 is above the second threshold.In response, instance 142 sets the connection closure rate, for closingconnections to PDB 214, at a closure rate that is mapped, in mappingdata, to transaction rates greater than the second threshold (e.g.,closing two connections per minute).

According to one or more embodiments, instance 142 determines theconnection closure rate based on an amount of time over which theconnections to the subject PDB are to be gradually closed. Based on anamount of time over which the connections are to be closed, instance 142determines the connection closure rate to be one or more of: a singlesteady rate based on which all connections to PDB 214 will be closed inthe specified amount of time; a number of groups of connections, to PDB214, to be closed at automatically-determined intervals over thespecified amount of time; two or more different connection closure ratesto be used during the specified amount of time in order to close allconnections to PDB 214 in the specified amount of time; etc.

Instance 142 closes the connections to PDB 214 either forcefully orgracefully. To illustrate, an instance gracefully closes a connection bycoordinating termination, of operations initiated via the connection,with users that requested the operations thereby allowing the users toperform termination processing prior to the connection closure. Aninstance forcefully closes a connection by, for example, forcingimmediate termination of operations initiated via the connection, i.e.,without allowing further processing to be performed on those operations.

Preparing the PDB Clone for the Second Round of Recovery

According to one or more embodiments, instance 152 does not allow anyoperations (read or write) to be processed over data in PDB clone 236while the second round of recovery is being performed on PDB clone 236(described in connection with step 516 of flowchart 500). For example,instance 152 disallows operations to be performed on PDB clone 236 byputting all operation requests for data in PDB clone 236 on hold (asdescribed above) for the duration of the second round of recovery.

Nevertheless, database server instance 152 does not close any connectionthat has been made to PDB clone 236 while the second round of recoveryis being performed on PDB clone 236. According to an embodiment, newconnections may not be made with PDB clone 236 while operations aredisallowed. According to another embodiment, instance 152 accepts newconnections requests, to connect to PDB clone 236, while operations onPDB clone 236 are disallowed. For example, instance 152 puts newconnection requests to connect to PDB clone 236 on hold (as describedabove) while the second round of recovery is being performed on PDBclone 236.

PDB Data Availability

According to one or more embodiments, the PDB data being moved is madeunavailable to the user for a minimal amount of time. To illustrate,during a moving operation that moves the data of a PDB from a source PDBat a source CDB to a PDB clone at a destination CDB, the source PDB isavailable for read and write operations throughout copying the files ofthe source PDB to the PDB clone and is also available for read and writeoperations while gathering redo information for the first round of redoon the PDB clone. Before the source instance stops accepting connectionrequests for the source PDB, the PDB clone is made available for newconnections and, depending on the tolerance for “stale” data asdescribed above, to read-only operations.

Nevertheless, the source PDB is available for read and write operationsuntil just before the second batch of redo information is collected inpreparation for making the PDB clone a functionally-equivalent copy ofthe source PDB. According to one or more embodiments, while the secondbatch of redo information is being collected, the PDB clone is availablefor read-only operations, as described in further detail above. For theamount of time that it takes to actually perform the second round ofrecovery on the PDB clone, the data in the PDB clone is completelyunavailable for operations thereon, though, according to one or moreembodiments, the PDB clone still accepts new connection requests.According to an embodiment, the source PDB is also unavailable for anyread or write operations while the second round of recovery is beingperformed. However, the time it takes to perform the second round ofrecovery is relatively short compared to the time it takes to performall other steps to make a functionally-equivalent copy of the sourcePDB.

Once the PDB clone is a functionally-equivalent copy of the source PDB,the PDB FE copy is made available for all kinds of requests, includingwrite requests. According to an embodiment in which PDB 214 is beingmoved (i.e., from CDB 210 to CDB 230), instance 152 sends a message toinstance 142 that the functionally-equivalent copy operation issuccessfully completed and that PDB 214 should be deleted. In responseto receiving this message, instance 142 deletes PDB 214 from CDB 210, asdepicted in FIG. 2D. In the case that connection requests to PDB 214 aretransparently forwarded to PDB clone 236 (now an FE copy), deletion ofPDB 214 leaves behind a tombstone with information for PDB 214 asdescribed in further detail below

Transparent Forwarding of Connections

After a pluggable database is moved from a source container database toa destination container database, users that previously connected to thepluggable database at the source container database will not be able tocontinue accessing the pluggable database data in the same way. Changinghow users connect to the moved pluggable database data generallyrequires adjusting connection information (e.g., connection strings inconfiguration files) across many user configurations used to access thepluggable database. Adjusting all information so that users may connectto the moved pluggable database without error can be an onerous,mistake-prone, and protracted task.

To illustrate, a particular user connects to a particular pluggabledatabase (PDB 214) via a connection service, such as database listener144. The database listener is configured to provide connections to theparticular pluggable database. In this example, the user accesses theconnection service based on a connection string, hard-coded into aconfiguration file, that includes an address of the host of the databaselistener and also a port number at which the database listener islistening.

While the particular user still requires access to PDB 214, PDB 214 ismoved to a different container database than that which originallycontained the pluggable database (i.e., from CDB 210 to CDB 230).Because PDB 214 is being removed from CDB 210, the connection that theuser was using to access PDB 214 is terminated.

According to one or more embodiments, at the time when source PDB 214ceases processing write operations, as described in connection with step512 of flowchart 500, database server instance 142 also closes PDB 214to new connection requests. For example, database server instance 142informs database listener 144, at server device 140, that PDB 214 is nolonger accepting new connections. In response to receiving thisinformation, listener 144 removes registration information, from aregister for listener 144, that indicates that PDB 214 is available fornew connections. After receiving the information that PDB 214 is notopen to new connections, database listener 144 receives one or moreconnection requests to connect to PDB 214. Listener 144 queries itsregistry for registration information for PDB 214 and, finding noregistration information for PDB 214 (which indicates that listener 144is not configured to provide new connections for PDB 214), returns errormessages in response to the one or more connection requests and does notprovide new connections to PDB 214.

Returning to the example of termination of a connection that a user wasusing to access PDB 214 because PDB 214 has moved, after PDB 214 ismoved from CDB 210, the user utilizes the connection string to request,from database listener 144, a new connection to PDB 214. However,database listener 144 can no longer provide connections to PDB 214because the PDB has been moved from CDB 210, which is the containerdatabase that listener 144 serves. As such, instead of returningconnection information, database listener 144 returns an error messageto the requesting user as described above.

Without transparent forwarding of requests for new connections to PDB214, all of the connection strings for any user that needs to connect toPDB 214 must be updated with the new address of the new host and alsopotentially with the new port number for the database listener that nowserves connections to PDB 214 at its new location.

As such, to facilitate a smooth transition of PDB data from a sourcecontainer database to a destination container database, according to oneor more embodiments, connection requests sent to the previous locationof a moved PDB are transparently forwarded to the new location of thePDB. The forwarded connection requests are received at the new locationand the requesting users are provided with connections to the moved PDB.More specifically, connection requests received by a connection servicethat served connections for a moved PDB (at its previous location) areautomatically forwarded to a connection service that serves connectionsto the PDB at its new location. The connection service at the newlocation processes the new connection requests as if the requests wereoriginally sent thereto.

Transparently forwarding of connection requests greatly increases theavailability of the relocated pluggable database in that users maycontinue to successfully request connections to the pluggable database(at the new location) using connection information that refers to thesource location. FIG. 6 depicts a flowchart 600 for transparentlyforwarding connection requests that request new connections to apluggable database that has been moved from a source location to adestination location.

At step 602, a particular pluggable database is moved from a sourcecontainer database to a destination container database. For example,database server instances 142 and 152 coordinate moving the data fromPDB 214 in CDB 210 to PDB clone 236 in CDB 230, as described above inconnection with flowchart 500. CDB 210 is distinct from CDB 230.

At step 604, in response to moving the particular pluggable database tothe destination container database, forwarding information is registeredwith a database listener that is configured to receive connectionrequests to connect to the particular pluggable database at the sourcecontainer database, wherein the forwarding information includesconnection information for the particular pluggable database at thedestination container database. For example, instance 152 configuresdatabase listener 154 to provide connections to PDB clone 236 uponrequest. Instance 152 causes forwarding information (identifyingdatabase listener 154) to be registered with database listener 144running at server device 140. For example, registering forwardinginformation with database listener 144 comprises including theforwarding information as a registry entry in a registry for databaselistener 144. Database listener 144 is the listener which, prior tomoving PDB 214 from CDB 210, provided new connections to PDB 214 on CDB210.

According to one or more embodiments, instance 152 may send forwardinginformation to instance 142 for registration with database listener 144at any time after PDB clone 236 is available for connections vialistener 154. For example, instance 152 sends the forwarding informationto be registered with database listener 144 once PDB clone 236 is fullyfunctional and instance 152 has registered connection information forPDB clone 236 with database listener 154. Based on the connectioninformation, database listener 154 may provide new connections inresponse to received requests for new connections to PDB clone 236 and,as such, is prepared to receive forwarded connection requests.

The forwarding information includes details that are needed for listener144 to be able to forward connection requests to listener 154. Forexample, the forwarding information includes a host address identifyingserver device 150 and also a port number identifying a port on serverdevice 150 at which listener 154 (now configured to process connectionrequests for PDB clone 236) is listening.

At step 606, after moving the particular pluggable database to thedestination container database, the database listener receives aparticular connection request, from a particular user, to connect to theparticular pluggable database at the source container database. Forexample, after PDB 214 has been moved from CDB 210, database listener144 receives a new connection request, from a particular user viadatabase client 112, to connect to PDB 214 at CDB 210.

At step 608, in response to receiving the particular connection requestto connect to the particular pluggable database at the source containerdatabase and based, at least in part, on the forwarding information, thedatabase listener automatically forwards particular information from theparticular connection request. For example, based on information in thenew connection request from the particular user, database listener 144determines that the new connection request is a request to connect toPDB 214 at CDB 210. Database listener 144 searches the information,registered therewith, for registration information associated with PDB214 as indicated in the request. Based on that search, listener 144identifies the forwarding information for PDB 214.

In response to determining that the registration information for PDB 214is forwarding information, listener 144 causes creation of a transformednew connection request based on (a) the received new connection request,and (b) the mapping data stored in the forwarding information registryrecord. Specifically, listener 144 causes the new transformed connectionrequest include the identifier of PDB clone 236 (instead of theidentifier of source PDB 214) as indicated in the mapping data. Dataidentifying the requesting user remains unchanged from the originalconnection request and the transformed connection request.

Database listener 144 causes the transformed new connection request tobe forwarded to database listener 154 using the information identifyingthe location of listener 154 included in the forwarding registrationinformation registered with listener 144.

In response to receiving the forwarded new connection request, databaselistener 154 processes the new connection request, based on theinformation in the forwarded message, as if the request had originallybeen sent to listener 154. Specifically, upon receiving the newconnection request, database listener 154 determines that the request isto connect to PDB clone 236 based on information included in therequest. Database listener 154 searches the information registeredtherewith to identify registration information associated with PDB clone236.

The results of that search indicate that connection information for PDBclone 236 is registered with listener 154. In response to determiningthat the registration information is connection information, listener154 provides, to the user that originally sent the request to listener144, a new connection to PDB clone 236 at CDB 230. Thus, databaselistener 144 transparently forwards new connection requests, submittedto listener 144, to database listener 154, which is capable ofconnecting the requesting user to the PDB that has moved without therequesting user having to update how the user connects to the PDB.

According to one or more embodiments, when database listener 144forwards a new connection request based on forwarding registrationinformation, database listener 144 also causes a message to be sent tothe requesting user informing the user that the connection request wasforwarded. Such message may include information from the forwardingregistration, such as connection information for listener 154.

According to one or more embodiments, forwarding registrationinformation is automatically registered with listener 144 when PDB 214is moved from CDB 210 to CDB 230 as described above. According toanother embodiment, the forwarding registration information isregistered with listener 144 in response to receiving a request toregister the forwarding registration information with listener 144.

Also, according to one or more embodiments, after registering theforwarding information with listener 144, database server instance 142creates a tombstone record in CDB 210 with the information for PDB 214.Presence of the tombstone record automatically prevents new PDBs frombeing created in CDB 210 with the same identifying information as PDB214, since a new PDB with the same identifying information as PDB 214would create confusion as to which new connection requests should beforwarded to listener 154 and which should cause a connection to becreated to the new PDB with the same identifying information.

According to one or more embodiments, database server instance 142 isconfigured to receive requests to cease forwarding connection requestsfor PDB 214 at CDB 210. For example, an administrator may ceaseforwarding connection requests once the administrator has updated allhard-coded connection strings with the new connection information for amoved PDB, at which point forwarding is no longer needed. Ceasingforwarding connection requests eliminates any overhead inherent intransparent forwarding. In response to receiving a cease forwardingrequest, database server instance 142 de-registers, from listener 144,the forwarding information that causes listener 144 to forward newconnection requests, that request a new connection to PDB 214 at CDB210, to listener 154. For example, de-registering the forwardinginformation comprises deleting forwarding registration information, fromthe registry of listener 144, which information was produced byregistering the forwarding information for PDB 214. Furthermore,receiving the request to cease forwarding causes database serverinstance 142 to remove any tombstone record with information for PDB214.

In some cases, the source and destination CDBs for a moved PDB are bothserved by a listener that has access to connection information for bothCDBs (such that the listener acts as a router for connection requestsfor both CDBs). In these cases, registration information for thelistener is updated when a PDB moves from the source to the destinationCDB, and the listener automatically routes connection requests for themoved PDB to the new location of the PDB without the need fortransparent forwarding.

Hardware Overview

According to one embodiment, the techniques described herein areimplemented by one or more special-purpose computing devices. Thespecial-purpose computing devices may be hard-wired to perform thetechniques, or may include digital electronic devices such as one ormore application-specific integrated circuits (ASICs) or fieldprogrammable gate arrays (FPGAs) that are persistently programmed toperform the techniques, or may include one or more general purposehardware processors programmed to perform the techniques pursuant toprogram instructions in firmware, memory, other storage, or acombination. Such special-purpose computing devices may also combinecustom hard-wired logic, ASICs, or FPGAs with custom programming toaccomplish the techniques. The special-purpose computing devices may bedesktop computer systems, portable computer systems, handheld devices,networking devices or any other device that incorporates hard-wiredand/or program logic to implement the techniques.

For example, FIG. 7 is a block diagram that illustrates a computersystem 700 upon which an embodiment of the invention may be implemented.Computer system 700 includes a bus 702 or other communication mechanismfor communicating information, and a hardware processor 704 coupled withbus 702 for processing information. Hardware processor 704 may be, forexample, a general purpose microprocessor.

Computer system 700 also includes a main memory 706, such as a randomaccess memory (RAM) or other dynamic storage device, coupled to bus 702for storing information and instructions to be executed by processor704. Main memory 706 also may be used for storing temporary variables orother intermediate information during execution of instructions to beexecuted by processor 704. Such instructions, when stored innon-transitory storage media accessible to processor 704, rendercomputer system 700 into a special-purpose machine that is customized toperform the operations specified in the instructions.

Computer system 700 further includes a read only memory (ROM) 708 orother static storage device coupled to bus 702 for storing staticinformation and instructions for processor 704. A storage device 710,such as a magnetic disk, optical disk, or solid-state drive is providedand coupled to bus 702 for storing information and instructions.

Computer system 700 may be coupled via bus 702 to a display 712, such asa cathode ray tube (CRT), for displaying information to a computer user.An input device 714, including alphanumeric and other keys, is coupledto bus 702 for communicating information and command selections toprocessor 704. Another type of user input device is cursor control 716,such as a mouse, a trackball, or cursor direction keys for communicatingdirection information and command selections to processor 704 and forcontrolling cursor movement on display 712. This input device typicallyhas two degrees of freedom in two axes, a first axis (e.g., x) and asecond axis (e.g., y), that allows the device to specify positions in aplane.

Computer system 700 may implement the techniques described herein usingcustomized hard-wired logic, one or more ASICs or FPGAs, firmware and/orprogram logic which in combination with the computer system causes orprograms computer system 700 to be a special-purpose machine. Accordingto one embodiment, the techniques herein are performed by computersystem 700 in response to processor 704 executing one or more sequencesof one or more instructions contained in main memory 706. Suchinstructions may be read into main memory 706 from another storagemedium, such as storage device 710. Execution of the sequences ofinstructions contained in main memory 706 causes processor 704 toperform the process steps described herein. In alternative embodiments,hard-wired circuitry may be used in place of or in combination withsoftware instructions.

The term “storage media” as used herein refers to any non-transitorymedia that store data and/or instructions that cause a machine tooperate in a specific fashion. Such storage media may comprisenon-volatile media and/or volatile media. Non-volatile media includes,for example, optical disks, magnetic disks, or solid-state drives, suchas storage device 710. Volatile media includes dynamic memory, such asmain memory 706. Common forms of storage media include, for example, afloppy disk, a flexible disk, hard disk, solid-state drive, magnetictape, or any other magnetic data storage medium, a CD-ROM, any otheroptical data storage medium, any physical medium with patterns of holes,a RAM, a PROM, and EPROM, a FLASH-EPROM, NVRAM, any other memory chip orcartridge.

Storage media is distinct from but may be used in conjunction withtransmission media. Transmission media participates in transferringinformation between storage media. For example, transmission mediaincludes coaxial cables, copper wire and fiber optics, including thewires that comprise bus 702. Transmission media can also take the formof acoustic or light waves, such as those generated during radio-waveand infra-red data communications.

Various forms of media may be involved in carrying one or more sequencesof one or more instructions to processor 704 for execution. For example,the instructions may initially be carried on a magnetic disk orsolid-state drive of a remote computer. The remote computer can load theinstructions into its dynamic memory and send the instructions over atelephone line using a modem. A modem local to computer system 700 canreceive the data on the telephone line and use an infra-red transmitterto convert the data to an infra-red signal. An infra-red detector canreceive the data carried in the infra-red signal and appropriatecircuitry can place the data on bus 702. Bus 702 carries the data tomain memory 706, from which processor 704 retrieves and executes theinstructions. The instructions received by main memory 706 mayoptionally be stored on storage device 710 either before or afterexecution by processor 704.

Computer system 700 also includes a communication interface 718 coupledto bus 702. Communication interface 718 provides a two-way datacommunication coupling to a network link 720 that is connected to alocal network 722. For example, communication interface 718 may be anintegrated services digital network (ISDN) card, cable modem, satellitemodem, or a modem to provide a data communication connection to acorresponding type of telephone line. As another example, communicationinterface 718 may be a local area network (LAN) card to provide a datacommunication connection to a compatible LAN. Wireless links may also beimplemented. In any such implementation, communication interface 718sends and receives electrical, electromagnetic or optical signals thatcarry digital data streams representing various types of information.

Network link 720 typically provides data communication through one ormore networks to other data devices. For example, network link 720 mayprovide a connection through local network 722 to a host computer 724 orto data equipment operated by an Internet Service Provider (ISP) 726.ISP 726 in turn provides data communication services through the worldwide packet data communication network now commonly referred to as the“Internet” 728. Local network 722 and Internet 728 both use electrical,electromagnetic or optical signals that carry digital data streams. Thesignals through the various networks and the signals on network link 720and through communication interface 718, which carry the digital data toand from computer system 700, are example forms of transmission media.

Computer system 700 can send messages and receive data, includingprogram code, through the network(s), network link 720 and communicationinterface 718. In the Internet example, a server 730 might transmit arequested code for an application program through Internet 728, ISP 726,local network 722 and communication interface 718.

The received code may be executed by processor 704 as it is received,and/or stored in storage device 710, or other non-volatile storage forlater execution.

In the foregoing specification, embodiments of the invention have beendescribed with reference to numerous specific details that may vary fromimplementation to implementation. The specification and drawings are,accordingly, to be regarded in an illustrative rather than a restrictivesense. The sole and exclusive indicator of the scope of the invention,and what is intended by the applicants to be the scope of the invention,is the literal and equivalent scope of the set of claims that issue fromthis application, in the specific form in which such claims issue,including any subsequent correction.

What is claimed is:
 1. A computer-executed method comprising: receivingan instruction to clone, to a destination location, a particularpluggable database at a source location; in response to receiving theinstruction: determining an initial time stamp that marks a timeoccurring before any files in the particular pluggable database arecopied in connection with the received instruction to clone; copyingfiles, included in the particular pluggable database, to the destinationlocation to produce a copy of the particular pluggable database at thedestination location; determining a final time stamp that marks a timeoccurring after copying the files included in the particular pluggabledatabase is complete; collecting, from information for the particularpluggable database at the source location, redo information that wasrecorded between times marked by the initial time stamp and the finaltime stamp; based, at least in part, on the redo information, performingrecovery on the copy of the particular pluggable database; wherein atleast one of the steps of copying, collecting, and performing recoveryare performed, at least partially, while the particular pluggabledatabase is in read-write mode; and wherein the method is performed byone or more computing devices.
 2. The method of claim 1, wherein: thefiles included in the particular pluggable database include undoinformation for the particular pluggable database; copying the filescomprises copying the undo information to produce a copy of the undoinformation; and the copy of the particular pluggable database comprisesthe copy of the undo information.
 3. The method of claim 2, whereinperforming recovery on the copy of the particular pluggable databasecomprises performing recovery on the copy of the undo information. 4.The method of claim 1, further comprising: maintaining mapping data thatmaps each file identifier in the particular pluggable database to acorresponding file identifier in the copy of the particular pluggabledatabase; wherein performing recovery on the copy of the particularpluggable database comprises performing recovery based, at least inpart, on the mapping data.
 5. The method of claim 1, wherein thedestination location is within a source container database that containsthe particular pluggable database.
 6. The method of claim 1, wherein thedestination location is within a destination container database otherthan a source container database that contains the particular pluggabledatabase.
 7. The method of claim 6, wherein collecting, from informationfor the particular pluggable database at the source location, the redoinformation that was recorded between times marked by the initial timestamp and the final time stamp further comprises: a first databaseserver instance, that is associated with the source container database,sending redo entries, collected from a redo log associated with thesource container database, to a second database server instance that isassociated with the destination container database.
 8. The method ofclaim 1, further comprising, after performing recovery on the copy ofthe particular pluggable database, creating one or more connections, tothe copy of the particular pluggable database at the destinationlocation, based on one or more connection initiation requests forconnections to the copy of the particular pluggable database.
 9. Themethod of claim 1, wherein the step of copying is performed, at leastpartially, while the particular pluggable database is in read-writemode.
 10. The method of claim 1, wherein the step of performing recoveryis performed, at least partially, while the particular pluggabledatabase is in read-write mode.
 11. One or more non-transitorycomputer-readable media storing one or more sequences of instructionswhich, when executed by one or more processors, cause: receiving aninstruction to clone, to a destination location, a particular pluggabledatabase at a source location; in response to receiving the instruction:determining an initial time stamp that marks a time occurring before anyfiles in the particular pluggable database are copied in connection withthe received instruction to clone; copying files, included in theparticular pluggable database, to the destination location to produce acopy of the particular pluggable database at the destination location;determining a final time stamp that marks a time occurring after copyingthe files included in the particular pluggable database is complete;collecting, from information for the particular pluggable database atthe source location, redo information that was recorded between timesmarked by the initial time stamp and the final time stamp; based, atleast in part, on the redo information, performing recovery on the copyof the particular pluggable database; wherein at least one of the stepsof copying, collecting, and performing recovery are performed, at leastpartially, while the particular pluggable database is in read-writemode.
 12. The one or more non-transitory computer-readable media ofclaim 11, wherein: the files included in the particular pluggabledatabase include undo information for the particular pluggable database;copying the files comprises copying the undo information to produce acopy of the undo information; and the copy of the particular pluggabledatabase comprises the copy of the undo information.
 13. The one or morenon-transitory computer-readable media of claim 12, wherein performingrecovery on the copy of the particular pluggable database comprisesperforming recovery on the copy of the undo information.
 14. The one ormore non-transitory computer-readable media of claim 11, wherein the oneor more sequences of instructions comprises instructions which, whenexecuted by one or more processors, cause: maintaining mapping data thatmaps each file identifier in the particular pluggable database to acorresponding file identifier in the copy of the particular pluggabledatabase; wherein performing recovery on the copy of the particularpluggable database comprises performing recovery based, at least inpart, on the mapping data.
 15. The one or more non-transitorycomputer-readable media of claim 11, wherein the destination location iswithin a source container database that contains the particularpluggable database.
 16. The one or more non-transitory computer-readablemedia of claim 11, wherein the destination location is within adestination container database other than a source container databasethat contains the particular pluggable database.
 17. The one or morenon-transitory computer-readable media of claim 16, wherein collecting,from information for the particular pluggable database at the sourcelocation, the redo information that was recorded between times marked bythe initial time stamp and the final time stamp further comprises: afirst database server instance, that is associated with the sourcecontainer database, sending redo entries, collected from a redo logassociated with the source container database, to a second databaseserver instance that is associated with the destination containerdatabase.
 18. The one or more non-transitory computer-readable media ofclaim 11, wherein the one or more sequences of instructions comprisesinstructions which, when executed by one or more processors, cause,after performing recovery on the copy of the particular pluggabledatabase, creating one or more connections, to the copy of theparticular pluggable database at the destination location, based on oneor more connection initiation requests for connections to the copy ofthe particular pluggable database.
 19. The one or more non-transitorycomputer-readable media of claim 1, wherein said copying is performed,at least partially, while the particular pluggable database is inread-write mode.
 20. The one or more non-transitory computer-readablemedia of claim 1, wherein said performing recovery is performed, atleast partially, while the particular pluggable database is inread-write mode.